<template>
  <div class="heritageRoad">
    <!-- header -->
    <Head />
    <Banner />
    <Nav />
    <!-- /header -->

    <div class="main">
      <div class="middle">
        <!-- 导航栏 -->
        <SideBar></SideBar>
        <!-- 导航栏 -->
        <!-- 通知公告 -->
        <div class="block">
          <!-- 标题 -->
          <div class="title">
            <h3>视频资料</h3>
          </div>
          <!-- 内容 -->
          <div class="content">
            <div
              class="articl"
              v-for="(item,index) in spzl"
              :key="index"
              @click="gonewActivityDetail(item.id)"
            >
              <h3>{{item.title}}</h3>
              <p>{{item.title}}</p>
              <div class="info">
                <span>入录者：</span>
                <span style="padding:1px;">{{item.adduser}}</span>
                <span>发表于：</span>
                <span>{{item.fbsj | dateFormat3}}</span>
                <span style="cursor: pointer;">查阅全文...</span>
              </div>
            </div>

            <!-- 分页 -->
            <el-pagination
              @size-change="sizeChange"
              @current-change="currentChange"
              :current-page="listQuery.page"
              :page-sizes="[10, 20, 30, 50]"
              :page-size="listQuery.limit"
              layout="total,sizes, prev, pager, next,jumper"
              :total="listQuery.total"
            ></el-pagination>
          </div>
        </div>
      </div>
    </div>
    <!-- footer -->
    <Footer></Footer>
    <!-- /footer -->
  </div>
</template>

<script>
import Head from "@/components/Head.vue";
import Banner from "@/components/Banner.vue";
import Nav from "@/components/Nav.vue";
import Footer from "@/components/Footer.vue";
import SideBar from "@/components/SideBar.vue";
export default {
  name: "HeritageRoad",
  components: {
    Head,
    Banner,
    Nav,
    Footer,
    SideBar,
  },
  data() {
    return {
      spzl: [], //通知公告
      // 页码
      listQuery: {
        total: 1,
        page: 1, //页码
        limit: 10, //每页条数
      },
    };
  },
  created() {
    this.getZxdt();
  },
  methods: {
    //首页接口
    getZxdt() {
      var query = {
        // id: "",
        page: this.listQuery.page,
        limit: this.listQuery.limit,
      };
      this.$axios
        .get("TCM/spzl", { params: query })
        .then((res) => {
          if (res.status == 200) {
            this.listQuery.total = res.data.count;
            this.spzl = res.data.data;
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // 跳转到通知公告详情页
    gonewActivityDetail(id) {
      // 点击数加1
      this.addCount(id);
    },
    sizeChange(limit) {
      this.listQuery.limit = limit;
      this.currentChange(1);
    },
    currentChange(page) {
      this.listQuery.page = page;
      this.getZxdt();
    },
    // 增加点击量接口
    addCount(id) {
      let queryData = {
        type: "5",
        id,
      };
      this.$axios
        .post("UpdTCM/addcount", queryData)
        .then((res) => {
          if (res.status == 200) {
            this.$router.push({ path: `/videoMaterialDetail/${id}` });
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
  },
};
</script>

<style lang="less" scoped>
@media screen and (max-width: 1200px) {
  .heritageRoad .main {
    margin: 0 !important;
  }
}
.heritageRoad {
  background: url("../assets/image/diwen.jpg") repeat-y;
  // 通知公告
  .main {
    margin: 0 auto;
    margin: 0 25% 0;
    height: 100%;
    background-color: #ffffff;
    overflow: hidden;
    .middle {
      height: 100%;
      padding: 0 10px 10px;
      background-color: #ffffff;
      box-sizing: border-box;
      margin-top: 20px;
      display: flex;
      justify-content: space-between;
      .block {
        flex: 1;
        margin-left: 20px;
        background-color: #ffffff;
        border: 0.5px solid #ebe4d9;
        border-top: none;
        .content {
          padding: 10px 20px 0;
          margin-bottom: 40px;
          .articl {
            border-bottom: 1px dotted #eaeaea;
            h3 {
              color: #003399;
              text-decoration: underline;
              margin: 18px 0 0 0;
              width: 480px;
              overflow: hidden;
              text-overflow: ellipsis;
              display: -webkit-box;
              -webkit-line-clamp: 1;
              -webkit-box-orient: vertical;
            }
            p {
              margin: 10px 0;
              font-size: 16px;
              // font-weight: 500;
              color: #666;
              overflow: hidden;
              text-overflow: ellipsis;
              display: -webkit-box;
              -webkit-line-clamp: 1;
              -webkit-box-orient: vertical;
            }
            .info {
              margin-bottom: 10px;
              display: flex;
              justify-content: space-between;
              span:nth-of-type(odd) {
                font-size: 16px;
                font-weight: normal;
                color: #666;
              }
              span:nth-of-type(even) {
                margin-right: 50px;
                font-size: 13px;
                color: #ff6600;
              }
              span:last-child {
                font-size: 13px;
                color: #0000ee;
                text-decoration: underline;
              }
            }
          }
          .articl:last-child {
            border-bottom: none;
          }
        }
      }
    }
  }
  .el-pagination {
    margin-top: 20px;
    padding: 0;
    text-align: center;
  }
}
</style>
